import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  // 命名路由 this.$router.push({name:'路由名字',params:{}})
  { path: '/login', name: 'login', component: () => import('@/views/login') },
  // 一般父路由name不用写
  {
    path: '/',
    component: () => import('@/views/layout'),
    children: [
      { path: '', name: 'home', component: () => import('@/views/home') },
      { path: 'qa', name: 'qa', component: () => import('@/views/qa') },
      { path: 'video', name: 'video', component: () => import('@/views/video') },
      { path: 'my', name: 'my', component: () => import('@/views/my') }
    ]
  },
  { path: '/search', name: 'search', component: () => import('@/views/search') },
  {
    path: '/article/:articleId',
    name: 'article',
    component: () => import('@/views/article'),
    props: true
  },
  {
    path: '/user/profile',
    name: 'user-profile',
    component: () => import('@/views/user-profile')
  }
]

const router = new VueRouter({
  routes
})

export default router
